package cn.tedu.charging.device.dao.mapper;

import cn.tedu.charging.device.pojo.po.StationPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 一次查询
 */
@Mapper
public interface StationAllMapper extends BaseMapper<StationPO> {

    /**
     * 根据枪ID查询场站信息
     * 子查询的方式 嵌套查询
     * 1 通过枪id 查询 桩id
     * 2 通过桩id 查询 站id
     * 3 通过站id 查询 站的 名称和运营商id
     * @param gunId
     * @return
     */
    @Select("SELECT id,station_name,operator_id FROM " +
            "charging_station WHERE id = " +
            "(SELECT station_id FROM charging_pile_info " +
            "WHERE id = (SELECT pile_id FROM charging_gun_info " +
            "WHERE id = #{gunId}))")
    StationPO getStationInfoByGunId(Integer gunId);


}
